﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

    public partial class MasterPage : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string strLang = Request.QueryString["l"] != null ? Request.QueryString["l"] : null;
                if (string.IsNullOrEmpty(strLang))
                {
                    if (Session["Lang"] == null && string.IsNullOrEmpty(hachiCookies.getCookieValue("Lang")))
                        strLang = "vi-VN";
                    else
                    {
                        try
                        {
                            strLang = Session["Lang"].ToString();
                        }
                        catch (Exception)
                        {
                            strLang = hachiCookies.getCookieValue("Lang");
                        }
                    }
                }
                else
                {
                    switch (strLang)
                    {
                        case "en-US":
                            break;
                        case "ja-JP":
                            break;
                        case "vi-VN":
                            break;
                        default:
                            strLang = "vi-VN";
                            break;
                    }
                }
                if (Session["Lang"] == null || Session["Lang"].ToString() != strLang)
                {
                    Session["Lang"] = strLang;
                    hachiCookies.setCookieValue("Lang", strLang);
                }

                ltrLang.Text = "<script src='js/lang/" + strLang + "/lang.js'></script><script src='js/lang/" + strLang + "/hachicommom.js'></script><script>var lang= '" + strLang + "'</script>";



            }
        }



        protected void lbt_vi_Click(object sender, EventArgs e)
        {
            string strLang = "";
            switch (((LinkButton)sender).ID)
            {
                case "lbt_en":
                    strLang = "en-US";
                    break;
                case "lbt_ja":
                    strLang = "ja-JP";
                    break;
                default:
                    strLang = "vi-VN";
                    break;
            }
            if (Session["Lang"] == null || Session["Lang"].ToString() != strLang)
            {
                Session["Lang"] = strLang;
                hachiCookies.setCookieValue("Lang", strLang);
            }

            ltrLang.Text = "<script src='js/lang/" + strLang + "/lang.js'></script><script src='js/lang/" + strLang + "/hachicommom.js'></script><script>var lang= '" + strLang + "'</script>";


        }
        
}